<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商城设置</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" media="all">
    <style>
        .setting-container {
            padding: 20px;
        }
        .setting-container input {
            width: 60px;
            text-align: center;
            padding-left: 0;
        }
        .setting-container .layui-inline {
            display: flex;
            align-items: center;
        }
    </style>
</head>

<body>
    <div class="setting-container">

        <!-- 搜索 -->
        <div class="searchInput">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>交易设置</legend>
            </fieldset>
            <form class="layui-form" action="" lay-filter="resets">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <span style="color:red; font-size:16px;">* </span>待付款订单取消时间：<input class="layui-input" name="orderCancelTime" placeholder="输入分钟数" autocomplete="off"> &nbsp;&nbsp; 分钟内未付款，自动取消订单
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <span style="color:red; font-size:16px;">* </span>订单自动确认时间：<input class="layui-input" name="orderAutoArrival" placeholder="天数" autocomplete="off"> &nbsp;&nbsp; 天，自动确认到货
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label" style="padding: 0; width: auto; line-height: 37px;"><span style="color:red; font-size:16px;">* </span>分销消费门槛：</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 300px;text-align: left;padding: 10px;" name="buyLimit" lay-verify="required|number" lay-reqtext="购买消费限制是必填项，岂能为空？" placeholder="请输入购买消费限制"
                            autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="padding: 0; width: auto; line-height: 37px;"><span style="color:red; font-size:16px;">* </span>提现手续费费率配置：</label>
                    <div class="layui-input-block">
                        <input type="text" style="width: 260px;text-align: left;padding: 10px;" max="3" min="1" name="cashOutRate" lay-verify="required|number" lay-reqtext="不能为空" placeholder="请输入提现手续费费率"
                            autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <span style="color:red; font-size:16px;">* </span>商品退换货地址：<textarea style="width: 300px;" placeholder="请输入商品退换货地址" name="returnAddress" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <span style="color:red; font-size:16px;margin-left:40px;">* </span>提现规则：<textarea style="width: 300px;" placeholder="请输入提现规则" name="withdrawalRules" class="layui-textarea"></textarea>
                    </div>
                </div>
                <input type="hidden" name="confType">
                <input type="hidden" name="confId">
                <button class="layui-btn" data-type="reload" lay-submit="" lay-filter="saveForm">保存</button>
            </form>
        </div>
    </div>

</body>

<script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
<script src="../utils.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form,
            $ = layui.jquery;


        ajax({
            path: "/order/getSysOrderConf",
            type: "GET",
            success: function (res) {
                form.val("resets", res)
            }
        }, $)


        // 搜索
        form.on("submit(saveForm)", function(e){
            if (e.field.cashOutRate < 0 || e.field.cashOutRate > 100) {
                layer.msg("取值范围在0-100之间")
                return false;    
            }

            ajax({
                path: "/order/createOrUpdateSysOrderConf",
                type: "POST",
                data: e.field,
                success: function (res) {
                    layer.msg("更新成功！")
                }
            }, $)

            return false;
        })
    });
</script>

</html>